import { pubRequire } from '@utils/public'
const baseUrl = '/coupons'
const courseUrl = '/goods/courses'
// 根据学院ID查询课程信息
export function getColleges(params, callBack, errBack) {
  return pubRequire('get', `${courseUrl}`, params, callBack, errBack)
}
// 根据商品ids查询商品课程信息
export function getCollegeList(params, callBack, errBack) {
  return pubRequire('post', `${courseUrl}/ids`, params, callBack, errBack)
}
// 优惠券列表
export function getCoupons(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}`, params, callBack, errBack)
}
// 优惠券用户列表
export function getCouponsUsers(couponId, params, callBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/${couponId}/users`,
    params,
    callBack,
    errBack
  )
}
// 添加优惠券
export function addtCoupons(params, callBack, errBack) {
  return pubRequire('post', `${baseUrl}`, params, callBack, errBack)
}
// 修改优惠券
export function eidtCoupons(couponId, params, callBack, errBack) {
  return pubRequire('put', `${baseUrl}/${couponId}`, params, callBack, errBack)
}
// 获取优惠券详情
export function getCouponsDetail(couponId, params, callBack, errBack) {
  if(params.type === 'public') { params.type = 'common' }
  return pubRequire('get', `${baseUrl}/${couponId}`, params, callBack, errBack)
}

//公用优惠券上架
export function collegesUpShelf(couponId,callBack, errBack) {
  return pubRequire('put', `${baseUrl}/${couponId}/up-shelf`,{},callBack, errBack)
}

//公用优惠券下架
export function collegesDownShelf(couponId, callBack, errBack) {
  return pubRequire('put', `${baseUrl}/${couponId}/down-shelf`,{}, callBack, errBack)
}


//商品优惠券顶置
export function couponsTop(couponId, callBack, errBack) {
  return pubRequire('put', `${baseUrl}/${couponId}/top?type=goods`,{}, callBack, errBack)
}

//商品优惠券取消顶置
export function couponsDown(couponId, callBack, errBack) {
  return pubRequire('put', `${baseUrl}/${couponId}/down?type=goods`,{}, callBack, errBack)
}

//优惠券领取数量和消耗数量统计
export function couponsNumber(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/data`,params, callBack, errBack)
}


//优惠券领取情况折线图统计
export function couponCollection(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/daily-data`,params, callBack, errBack)
}


